import request from '@/utils/request'

// 获取所有用户
export function getAllUsers() {
  return request({
    url: '/api/user/list',
    method: 'get'
  })
}

// 获取某车间所有用户
export function getUsersByGroup(groupId) {
  return request({
    url: '/api/user/listByGroup',
    method: 'get',
    params: { id: groupId }
  })
}

// 创建用户
export function createUser(data) {
  return request({
    url: '/api/user/create',
    method: 'post',
    data
  })
}

// 更新用户
export function updateUser(id, data) {
  return request({
    url: `/api/user/${id}`,
    method: 'put',
    data
  })
}

// 删除用户
export function deleteUser(id) {
  return request({
    url: `/api/user/${id}`,
    method: 'delete'
  })
}

// 重置用户密码
export function resetUserPassword(userId, data) {
  return request({
    url: `/api/user/${userId}/password`,
    method: 'post',
    data
  })
}

// 获取用户详情
export function getUserById(id) {
  return request({
    url: `/api/user/${id}`,
    method: 'get'
  })
}

// 获取当前用户信息
export function getCurrentUser() {
  return request({
    url: '/api/user/info',
    method: 'get'
  })
}

// 获取员工列表
export function getEmployees(params) {
  return request({
    url: '/api/user/list',
    method: 'get',
    params
  })
}

// 获取某车间员工列表
export function getEmployeesByGroup(id) {
  return request({
    url: `/api/user/listByGroup`,
    method: 'get',
    params: {
      id
    }
  })
}

// 获取单个员工信息
export function getEmployee(id) {
  return request({
    url: `/api/employees/${id}`,
    method: 'get'
  })
}

// 创建员工
export function createEmployee(data) {
  return request({
    url: '/api/employees',
    method: 'post',
    data
  })
}

// 更新员工信息
export function updateEmployee(id, data) {
  return request({
    url: `/api/employees/${id}`,
    method: 'put',
    data
  })
}

// 删除员工
export function deleteEmployee(id) {
  return request({
    url: `/api/employees/${id}`,
    method: 'delete'
  })
}

// 重置员工密码
export function resetEmployeePassword(id, data) {
  return request({
    url: `/api/employees/${id}/password`,
    method: 'put',
    data
  })
} 